#include<cstdio>
using namespace std;
void fun(int n,char a,char b,char c,int top_num)
{
	if(n==1)
	{
		printf("%c->%d->%c\n",a,top_num,b);
		return ;
	}
	fun(n-1,a,c,b,top_num);
	printf("%c->%d->%c\n",a,top_num+n-1,b);
	fun(n-1,c,b,a,top_num);
}

int main()
{
	int n;
	char a,b,c;
	scanf("%d %c %c %c",&n,&a,&b,&c);
	fun(n,a,b,c,1);
    return 0;
}
